package com.panda.expand;

import com.panda.pojo.Context;

public abstract class Expression {

    private Expression next;

    public void setNext(Expression next) {
        this.next = next;
    }

    public Expression getNext() {
        return next;
    }

    public Expression next(Expression expression) {
        this.next = expression;
        return this.next;
    }

    public void parse(String e, Context context) {

        if (canParse(e, context)) {

            doParse(e, context);


        } else if (next != null) {
            next.parse(e, context);
        }

    }

    public boolean canParse(String s, Context context) {
        return false;
    }

    public abstract void doParse(String e, Context context);


}